//package com.ruoyi.mq.kafka.handler;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.kafka.listener.DeadLetterPublishingRecoverer;
//import org.springframework.kafka.listener.SeekToCurrentErrorHandler;
//
//public class KafkaErrorHandler {
//
//    @Bean
//    public SeekToCurrentErrorHandler errorHandler(
//            @Value("${spring.kafka.listener.retry-attempts:3}") int maxAttempts
//    ) {
//        // 重试3次后转发到死信队列
//        DeadLetterPublishingRecoverer dlqRecoverer = new DeadLetterPublishingRecoverer(
//                kafkaTemplate,
//                (record, ex) -> new TopicPartition(record.topic() + ".DLQ", record.partition())
//        );
//        return new SeekToCurrentErrorHandler(dlqRecoverer, maxAttempts);
//    }
//}
